home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / program / eflibpt4.zip / DEMO / STRINGS / PARSEXPR.PAS < prev    next >
Pascal/Delphi Source File  |  1996-08-09  |  957b  |  29 lines

  1. { Borland Pascal Extended Function Library - EFLIB (C) Johan Larsson, 1996
  2.   Demonstration; parsing expression using the string parser object
  3.  
  4.   EFLIB IS PROTECTED BY THE COPYRIGHT LAW AND MAY NOT BE COPIED, SOLD OR
  5.   MANIPULATED. FOR MORE INFORMATION, SEE PROGRAM MANUAL! THIS DEMONSTRAT-
  6.   ION PROGRAM MAY FREELY BE USED AND DISTRIBUTED.                          }
  7.  
  8.  
  9.  
  10. uses EFLIBDEF, EFLIBINI, EFLIBTXT;
  11.  
  12.  
  13. var Expression : ParserObjectType; SomeExpression : string; Index : word;
  14.  
  15. begin
  16.      SomeExpression := '12*4-(1+2)/7';
  17.  
  18.      with Expression do begin
  19.           Initialize (@SomeExpression, { Address of string resource }
  20.                       ['+', '-', '*', '/', '(', ')']); { Separators }
  21.  
  22.           { Separate tokens out of string }
  23.           for Index := 1 to Tokens do
  24.               Write ('*', Token (Index), '* ');
  25.           WriteLn;
  26.  
  27.           Intercept; { Intercept (dispose separator allocation) }
  28.      end;
  29. end.